export const localUitl = {};
let session = window.sessionStorage;
let saveSessionMap = {};


localUitl.getToken = function () {
  let tokenObj = localUitl.getItem("userData");
  return tokenObj && tokenObj.access_token || ""
}


localUitl.getItem = function (key) {
  if (saveSessionMap[key]) {
    return saveSessionMap[key];
  } else {
    return this.getSessionItem(key);
  }
}


localUitl.getSessionItem = function (key) {
  return JSON.parse(session.getItem(key));
}
localUitl.setSessionItem = function (key, value) {
  session.setItem(key, JSON.stringify(value));
}
localUitl.removeSessionItem = function (key) {
  session.removeItem(key);
}
